package com.yin.good.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yin.good.entity.GoodInfoEntity;
import com.yin.good.jpa.GoodInfoJPA;
import com.yin.good.service.GoodService;

/**
*@author LSY
*Time: 2018年12月26日下午5:42:30
*
*
*/
@RestController
@RequestMapping("/good")
public class GoodController {

	@Autowired
	private GoodInfoJPA goodJPA;
	
	
	@Autowired
	private GoodService goodService;
	
	@GetMapping(value = "/{id}")
	public GoodInfoEntity getGoodInfoById(@PathVariable Long id) {
		return goodService.findById(id);
	}
	
	@GetMapping(value = "/all")
	public List<GoodInfoEntity> getGoods(){
		return goodJPA.findAll();
	}
	
	@GetMapping(value = "/del/{id}")
	public void del(@PathVariable Long id){
		goodService.delGood(id);
	}
}
